CGIs: How They Work

When there is no CGI present on the server and user access a web page on a WWW server, the flow of events is something like:
  1. the user's client software (a web browser) requests the page from the server
  2. the server (NetPresenz) looks for the page and returns the content
  3. the browser displays the web page
Note, that as the browser retrieves the returned page it parses the text looking for other graphics or links it may need to download to complete the layout of the page. (Typically embedded graphics. If other files are required the browser will repeat this process to retrieve those files.)

CGIs come in at step 2 in the above list. When the user accesses a link which is a CGI the process looks like this:

  1. the user's browser requests the 'page', in this case a CGI, from the server (the request can include information from forms on the page, if you use a submit button)
  2. the server (NetPresenz) looks for the CGI and passes it any information the browser included to be passed on to the CGI (typically information which has been typed into a form)
  3. the CGI processes the information and returns a valid Web page, or a redirection header to the server
  4. the server returns the information to the browser
  5. the browser displays the web page
The CGI doesn't know anything about the client except what has been passed to it by the browser. The CGI doesn't know anything about transferring information across the network. All it knows is how to talk to the server. Similarly the browser doesn't know that the web page which has been returned to it has anything to do with a CGI- as far as it is concerned it is receiving normal HTML.

Previous Next
Introduction to CGIs Some Simple Examples